<script>
<!--
var sort_by = '';
var sort_order = 0;
var current_view = '';
var page = 1;

function listReload(page)
{
    $('#indexAjax').html('<div align="center"><div class="loader_admin"></div></div>');
    $('#indexAjax').load('<?php echo url_for('@cms_edit?cms_id='.$cms->cms_id) ?>?'+$('#filterSearch').serialize(), {
        sort_by:      sort_by,
        sort_order:   sort_order,
        page:         page,
        view:         current_view,
    });
}

function sort(type, default_order) {
    if (type != sort_by) {
        sort_by = type;
        sort_order = default_order;
    } else if(sort_order) {
        sort_order = 0
    } else {
        sort_order = 1;
    }
    listReload(1);
}
-->
</script>
<h1>Tin tức</h1>
<div id="EditCmsForm" class='backend_form'>
  <form id="editCms" action="<?php echo url_for('@cms_edit?cms_id='.((isset($cms))? ($cms->cms_id):"").''); ?>" method="post"  enctype="multipart/form-data">
    <table>
      <?php echo $cms_form['name']->renderRow();  ?>
      <?php echo $cms_form['cms_category_id']->renderRow();  ?>
      <?php echo  $cms_form['picture']->renderRow(); ?>
      <?php if(isset($cms) && $cms->picture != null): ?> 
          <tr>
            <td></td>
            <td>
                <img style="width: 150px; height: 130px;" src="/uploads/cms/<?php echo $cms->picture;?> "/>
            </td>
          </tr>  
      <?php endif ?>
      
      <tr>
      	<th valign="top">
          <?php echo $cms_form['description']->renderLabel();  ?>	
        </th>
        <td>
          <?php echo $cms_form['description']->render();  ?>
        </td>
      </tr>
      
      <tr>
      	<th>
          <?php echo $cms_form['content']->renderLabel();  ?>
        </th>
      </tr>
      <tr>
      	<td colspan="2">
	      <?php echo $cms_form['content']->render(array('class' => 'editor'));  ?>
      	</td>
      </tr>
      <?php echo $cms_form['is_active']->renderRow();  ?>
      <?php echo $cms_form['_csrf_token'];  ?>
      <tr><td colspan="2" style="text-align:center">
      	<input type='reset' value='Reset' />
        <input  id="fs" type="submit" value="<?php echo "Save" ?>"/>
		<?php if (isset($status) && $status == false) :?>
			<div></span>Tên đã tồn tại</span></div>
            <script>
                    window.location.href = document.location.href;
            </script>
		<?php endif ?>
      </td></tr>
    </table>
  </form>
</div>

<div style='padding-top:10px;'>
<div class="UITable">
  <div id="indexAjax" class='filter_form'>
    <?php include 'cmsListAjax.php' ?>
  </div>
</div>
</div>